#include <iostream>
using namespace std ;

int main (){
	int n ;// 数组中元素的个数 
	cin >> n ;
	
	int a[n+1] ;
	int count = 0 ;
	
	for (int i=1; i<=n; i++){
		cin >> a[i] ;
		if (0 == a[i])
			count ++ ;
	}
	
	for (int i=1; i<=n; i++){
		if (0 != a[i])
			cout << a[i] << " " ;
	}
	
	for (int i=1; i<=count; i++)
		cout << "0" << " " ;
		
	cout << endl ;
	return 0 ;
}
